﻿using MyToDo.Common.Models;
using Prism.Commands;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyToDo.ViewModels
{
    public class MenuViewModel: BindableBase
    {
        public MenuViewModel()
        {
            MemoItems = new ObservableCollection<MemoItem>();
            CreateMemoList();
            AddMemoCommand = new DelegateCommand(Add);
        }

        public void Add()
        {
            IsRightDrawerOpen = !IsRightDrawerOpen;
        }

        private bool isRightDrawerOpen;
        /// <summary>
        /// 右侧编辑窗口展开
        /// </summary>
        public bool IsRightDrawerOpen
        {
            get { return isRightDrawerOpen; }
            set { isRightDrawerOpen = value; RaisePropertyChanged(); }
        }
        public DelegateCommand AddMemoCommand { get; set; }

        private ObservableCollection<MemoItem> memoItems;
        public ObservableCollection<MemoItem> MemoItems
        {
            get { return memoItems; }
            set
            {
                memoItems = value;
                RaisePropertyChanged();
            }
        }

        void CreateMemoList()
        {
            for (int i = 0; i < 20; i++)
            {
                MemoItems.Add(new MemoItem()
                {
                    Title = "标题" + i,
                    Content = "测试数据..."
                });
            }
        }
    }
}
